/*
 * Copyright user2010
 * All rights reserved
 */

package org.myorg.applitest.jdbc.connection;

import org.myorg.applitest.mysql.names.Names;
import org.myorg.applitest.jdbc.Def;
import java.sql.ResultSet;

/**
 *
 * @author user
 */
public class ConAddAnm extends ConAbs{
    public ConAddAnm() throws Exception{
        super();
    }

    @Override
    public boolean doJob(String user, String password) throws Exception {
        this._dbConnection_.connect("", user, password);
        this._dbConnection_.executeUpdate(Def.useDB(Names.db));

        this._dbConnection_.executeQuerry(Def.countElements(Names.tableAnm));
        ResultSet result = this._dbConnection_.getResult();
        String strId = "";
        while(result.next())
        {
            strId = ((Integer)(result.getInt(1) +1)).toString();
        }

        String strCommand =  Def.insertIntoTable(Names.tableAnm) +
        Def.addField(strId) +
        Def.addField(this.strIdentiteNom_) +
        Def.addField(this.strIdentiteSexe_) +
        Def.addField(this.strIdProprietaire_) +
        Def.addField(this.strCastre_) +
        Def.addField(this.strEspece_) +
        Def.addField(this.strRace_) +
        Def.addField(this.strIdentiteDateNaissance_) +
        Def.addLastField(this.strIdentiteDateMort_);


        this._dbConnection_.executeUpdate(strCommand);
        this._dbConnection_.disconnect();

        return true;
    }

    public void setValues(
        String strIdentiteNom,
        String strIdentite,
        String strIdProprietaire,
        String strCastre,
        String strEspece,
        String strRace,
        String strIdentiteDateNaissance,
        String strIdentiteDateMort)
    {
        this.strIdentiteNom_ = strIdentiteNom;
        this.strIdentiteSexe_ = strIdentite;
        this.strIdProprietaire_ = strIdProprietaire;
        this.strCastre_ = strCastre;
        this.strEspece_ = strEspece;
        this.strRace_ = strRace;
        this.strIdentiteDateNaissance_ = strIdentiteDateNaissance;
        this.strIdentiteDateMort_ = strIdentiteDateMort;
        
    }


    protected String strIdentiteNom_;
    protected String strIdentiteSexe_;
    protected String strIdProprietaire_;
    protected String strCastre_;
    protected String strEspece_;
    protected String strRace_;
    protected String strIdentiteDateNaissance_;
    protected String strIdentiteDateMort_;
}
